﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace KingOfCSharp.iHunter.Plugins.BBS
{
    public class BbsPlugin : KingOfCSharp.iHunter.IChannelProvider
    {
        private System.Data.DataSet dataSet;

		#region IChannelProvider Members

		public IChannel CreateChannelInstance(string settings)
		{		

			try
			{
				BbsChannel channel = new BbsChannel(settings, this.dataSet);

				return channel;				
				
			}
			catch {
				return null;
			}
		}

		public System.Windows.Forms.UserControl GetChannelConfigureEditor()
		{
			return new BbsChannelConfigureControl();
		}

		public System.Windows.Forms.UserControl[] GetNewChannelWizardPages()
		{
			return new System.Windows.Forms.UserControl[] {
				new BbsChannelConfigureControl()
			};
		}

		public Type MessageViewerType
		{
            get { return typeof(KingOfCSharp.iHunter.Plugins.BBS.BbsItemViewer); }
		}

		public Type NewMessageEditorType
		{
            get { return typeof(KingOfCSharp.iHunter.Plugins.BBS.BbsNewItemEditor); }
		}

		public Type ReplyMessageEditorType
		{
            get { return typeof(KingOfCSharp.iHunter.Plugins.BBS.BbsReplyEditor); }
		}

		public System.Xml.XPath.XPathNavigator ContextualCommands
		{
			get { return null; }
		}

		#endregion

		#region IPlugin Members

		public Guid Guid
		{
			get { return new Guid("402623EE-37C1-48f8-8B65-F6AEFB17B9BE"); }
		}

		public void Initialize(IPluginClient client)
		{
            //this.dataSet = client.GetPluginDatabase();
            this.dataSet = new System.Data.DataSet();
		}

        public System.Windows.Forms.UserControl GetPluginConfigureEditor()
		{
            return null;
		}

		public event PluginErrorEventHandler ErrorOccur;

		#endregion

		#region IDisposable Members

		public void Dispose()
		{
			// Do nothing
		}

		#endregion

        #region IChannelProvider Members

        public IChannel CreateChannelInstance(ChannelInfo info)
        {
            try
            {
                BbsChannel channel = new BbsChannel(info.Settings, this.dataSet);

                return channel;

            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region IPlugin 成员


        public string Name
        {
            get { return "BBS Client"; }
        }

        public string Description
        {
            get { return "Getting posts and mails from Term BBS"; }
        }

        #endregion
        public Guid NewMesssageEditorGuid
        {
            get { return BbsItemEditorProvider.Guid; }
        }
    }
}
